import scipy
import numpy as np

matrix = np.array(
    [
        [1.0, 2.0, 3.0, 4.0],
        [5.0, 6.0, 7.0, 8.0],
        [9.0, 10.0, 11.0, 12.0],
        [13.0, 14.0, 15.0, 16.0],
    ]
)
u, s, vt = scipy.sparse.linalg.svds(matrix, k=1)
print(u, s, vt)
# [[-0.1347221]
#  [-0.3407576]
#  [-0.5467932]
#  [-0.7528288]], [38.62266], [[-0.428412  -0.4743725 -0.5203326 -0.566292]]

svd_matrix = u * s * vt
print(svd_matrix)
# array([[ 2.2291691,  2.4683154,  2.7074606,  2.9466066],
#        [ 5.6383204,  6.243202 ,  6.848081 ,  7.4529614],
#        [ 9.047472 , 10.018089 , 10.988702 , 11.959317 ],
#        [12.456624 , 13.792976 , 15.129323 , 16.465673 ]], dtype=float32)
